//
//  CYBankCell.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/7/7.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYBankCell.h"
@interface CYBankCell()
@property (nonatomic, strong) CYImageView *IMG;
@property (nonatomic, strong) CYLabel *nameLBL;
//@property (nonatomic, strong) CYView *line;
@end;
@implementation CYBankCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.IMG.hidden = self.line.hidden = NO;
    }
        return self;
}

- (CYImageView *)IMG{
    if (!_IMG) {
        _IMG = [[CYImageView alloc]initWithImage:_image
                                            size:CGSizeMake(AL(PT(93 - 18 * 2)), AL(PT(93 - 18 * 2)))
                                        isRadius:YES];
        _IMG.loadingView.hidden = NO;
        [self addSubview:_IMG];
        
        [_IMG mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(AL(PT(37)));
            make.centerY.equalTo(self);
            make.size.mas_equalTo(_IMG.bounds.size);
        }];
    }
    return _IMG;
}

- (CYLabel *)nameLBL{
    if (!_nameLBL) {
        _nameLBL = [[CYLabel alloc]initWithText:_bank_name size:AL(PT(30)) textcolor:ColorHex(0x333333)];
        [self addSubview:_nameLBL];
        
        [_nameLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_IMG.mas_right).with.offset(AL(PT(18)));
            make.centerY.equalTo(_IMG);
            make.size.mas_equalTo(_nameLBL.bounds.size);
        }];
    }
    return _nameLBL;
}
//
//- (CYView *)line{
//    if (!_line) {
//        _line = [[CYView alloc]initWithColor:ColorHex(0x888888)];
//        [self addSubview:_line];
//
//        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self).with.offset(AL(PT(37)));
//            make.bottom.equalTo(self.mas_bottom).with.offset(0);
//            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - AL(PT(37 * 2)), 0.5));
//        }];
//    }
//    return _line;
//}

- (void)setImage:(UIImage *)image{
    if (_image != image)
        _image = image;
    _IMG.loadingView.hidden = YES;
    _IMG.image = image;
}

- (void)setBank_name:(NSString *)bank_name{
    if (_bank_name != bank_name)
        _bank_name = bank_name;
    self.nameLBL.text = bank_name;
    [self updateNameLBL];
    
}

- (void)updateNameLBL{
    
    [_nameLBL mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(_nameLBL.bounds.size);
    }];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
